package com.eightywork.life.image;


import java.io.IOException;
import java.io.InputStream;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.text.Html;

public class MyImageGetter implements Html.ImageGetter {
	private Context context;

	public MyImageGetter(Context context) {
		this.context = context;
	}

	@Override
	public Drawable getDrawable(String source) {
		Drawable drawable = null;  
        InputStream inputStream = null;  
        try {  
            inputStream = context.getAssets().open(source);  
            Bitmap bitmap = BitmapFactory.decodeStream(inputStream);  
            drawable = new BitmapDrawable(bitmap);  
            drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());  
            bitmap = null;  
        } catch (Exception e) {  
            e.printStackTrace();  
        } finally {  
            if (inputStream != null) {  
                try {  
                    inputStream.close();  
                } catch (IOException e) {  
                    e.printStackTrace();  
                }  
            }  
        }  
        return drawable;  
	}

}
